'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up (queryInterface, Sequelize) {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
    const { INTEGER, STRING, DATE } = Sequelize;

    await queryInterface.createTable('resource', {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comment: '表ID',
      },
      classificate: {
        type: INTEGER,
        comment: '资源分类; 1- pdf; 2- mp4',
      },
      name: {
        type: STRING,
        comment: '资源名称',
      },
      url: {
        type: STRING,
        comment: '资源链接',
      },
      remarks: {
        type: STRING,
        comment: '资源备注',
      },
      createdAt: {
        type: DATE,
        allowNull: false,
      },
      updatedAt: {
        type: DATE,
        allowNull: false,
      },
    })
  },

  async down (queryInterface, Sequelize) {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable('resource');

  }
};
